package cn.cms.chuangjia.service.impl;

import java.util.List;

import cn.cms.chuangjia.domain.Menu;
import cn.cms.chuangjia.service.IMenuService;
import cn.cms.chuangjia.vo.Page;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import cn.cms.chuangjia.mapper.MenuMapper;

/**
 * menuService业务层处理
 * 
 * @author ruoyi
 * @date 2024-01-18
 */
@Service
@Cacheable(cacheNames = "menu",keyGenerator = "keyg")
public class MenuServiceImpl implements IMenuService
{
    @Autowired
    private MenuMapper menuMapper;

    /**
     * 查询menu
     * 
     * @param id menu主键
     * @return menu
     */
    @Override
    public Menu selectMenuById(Integer id)
    {
        return menuMapper.selectMenuById(id);
    }

    /**
     * 查询menu列表
     * 
     * @param menu menu
     * @return menu
     */
    @Override
    public Page<Menu> selectMenuList(Menu menu)
    {
        List<Menu> list = menuMapper.selectMenuList(menu);
        return Page.convert(PageInfo.of(list));
    }

    /**
     * 新增menu
     * 
     * @param menu menu
     * @return 结果
     */
    @Override
    @CacheEvict(allEntries = true,cacheNames = "menu")
    public int insertMenu(Menu menu)
    {
        return menuMapper.insertMenu(menu);
    }

    /**
     * 修改menu
     * 
     * @param menu menu
     * @return 结果
     */
    @Override
    public int updateMenu(Menu menu)
    {
        return menuMapper.updateMenu(menu);
    }

    /**
     * 批量删除menu
     * 
     * @param ids 需要删除的menu主键
     * @return 结果
     */
    @Override
    public int deleteMenuByIds(Integer[] ids)
    {
        return menuMapper.deleteMenuByIds(ids);
    }

    /**
     * 删除menu信息
     * 
     * @param id menu主键
     * @return 结果
     */
    @Override
    public int deleteMenuById(Integer id)
    {
        return menuMapper.deleteMenuById(id);
    }

    @Override
    public List<Menu> selectMenuTree(Menu menu) {
        return menuMapper.selectMenuTree(menu);
    }

    @Override
    public Menu selectMenu(Integer id) {
        return menuMapper.selectMenu(id);
    }
}
